package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dkd.manage.domain.vo.RepairContentVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.RepairContent;
import com.dkd.manage.service.IRepairContentService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 维修分类管理Controller
 * 
 * @author czq
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/manage/repairContent")
public class RepairContentController extends BaseController
{
    @Autowired
    private IRepairContentService repairContentService;

    /**
     * 查询维修分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairContent repairContent)
    {
        startPage();
        List<RepairContentVo> voList = repairContentService.selectRepairContentVoList(repairContent);
        return getDataTable(voList);
    }

    /**
     * 导出维修分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:export')")
    @Log(title = "维修分类管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RepairContent repairContent)
    {
        List<RepairContent> list = repairContentService.selectRepairContentList(repairContent);
        ExcelUtil<RepairContent> util = new ExcelUtil<RepairContent>(RepairContent.class);
        util.exportExcel(response, list, "维修分类管理数据");
    }

    /**
     * 获取维修分类管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(repairContentService.selectRepairContentById(id));
    }

    /**
     * 新增维修分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:add')")
    @Log(title = "维修分类管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairContent repairContent)
    {
        return toAjax(repairContentService.insertRepairContent(repairContent));
    }

    /**
     * 修改维修分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:edit')")
    @Log(title = "维修分类管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairContent repairContent)
    {
        return toAjax(repairContentService.updateRepairContent(repairContent));
    }

    /**
     * 删除维修分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:repairContent:remove')")
    @Log(title = "维修分类管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(repairContentService.deleteRepairContentByIds(ids));
    }
}
